admin: Initialize /var more fully
authorColin Walters <walters@verbum.org>
Tue, 18 Sep 2012 12:39:26 +0000 (08:39 -0400)
committerColin Walters <walters@verbum.org>
Tue, 18 Sep 2012 12:58:07 +0000 (08:58 -0400)
This helps out gnome-ostree, because gdm needs /var/lib for example.

src/ostree/ot-admin-functions.c

index 520968509ca3c9e21be796721c903d01961d28af..1d41826ffca29b5baa99d723519295f015a529f6 100644 (file)
@@ -65,12 +65,14 @@ ot_admin_ensure_initialized (GFile         *ostree_dir,
         }
     }
 
-  /* Ensure a few subdirectories of /var exist, since we need them for
-     dracut generation */
+  /* Ensure core subdirectories of /var exist, since we need them for
+   * dracut generation, and the host will want them too.
+   */
   g_clear_object (&dir);
   dir = ot_gfile_get_child_build_path (ostree_dir, "var", "log", NULL);
   if (!ot_gfile_ensure_directory (dir, TRUE, error))
     goto out;
+
   g_clear_object (&dir);
   dir = ot_gfile_get_child_build_path (ostree_dir, "var", "tmp", NULL);
   if (!ot_gfile_ensure_directory (dir, TRUE, error))
@@ -81,6 +83,22 @@ ot_admin_ensure_initialized (GFile         *ostree_dir,
       goto out;
     }
 
+  g_clear_object (&dir);
+  dir = ot_gfile_get_child_build_path (ostree_dir, "var", "lib", NULL);
+  if (!ot_gfile_ensure_directory (dir, TRUE, error))
+    goto out;
+
+  g_clear_object (&dir);
+  dir = ot_gfile_get_child_build_path (ostree_dir, "var", "run", NULL);
+  if (!g_file_test (ot_gfile_get_path_cached (dir), G_FILE_TEST_IS_SYMLINK))
+    {
+      if (symlink ("../run", ot_gfile_get_path_cached (dir)) < 0)
+        {
+          ot_util_set_error_from_errno (error, errno);
+          goto out;
+        }
+    }
+
   ret = TRUE;
  out:
   return ret;